<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="CONTENT_LOCALES_COLLECTION_KEY" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" scope="page" />

<atleap:javascript formName="searchForm" staticJavascript="false" dynamicJavascript="true" method="validateForm" cdata="false" />

<script type="text/javascript">
  function doSubmitSearchForm(frm)
  {
    if(frm["noField-phrase-input"].value.length> 0)
      frm["noField-phrase"].value = quote(frm["noField-phrase-input"].value)
    else if(frm["noField-phrase"].value.length> 0)
      frm["noField-phrase"].value = ''
    doMakeQuery(frm.query);

    if(frm.query.value.length <= 0) {
      alert("<atleap:message key="core.search.form.query" var="queryLabel"/><atleap:message key="core.commons.errors.required" arg0="${queryLabel}" />");
      return false;
    }

    return doCheckLuceneQuery(frm.query);
  }
</script>

    <atleap:messages property="searchQueryInvalid" /><br />

<atleap:form action="core/search/search" onsubmit="var result = doSubmitSearchForm(this); disableButtons(this, result); return result;">
    <table cellpadding="0" cellspacing="0" border="0" class="modificationTable">
        <tr>
            <th><atleap:message key="core.search.form.all" /></th>
            <td>
                <input name="noField-andModifier" value="+|0" type="hidden" />
                <input type="text" name="noField-and" class="text" />
            </td>
        </tr>
        <tr>
            <th><atleap:message key="core.search.form.exact" /></th>
            <td><input name="noField-phraseModifier" value="+|+" type="hidden" />
                <input type="text" name="noField-phrase-input" class="text" />
                <input type="hidden" name="noField-phrase" />
            </td>
        </tr>
        <tr>
            <th><atleap:message key="core.search.form.atleast" /></th>
            <td>
                <input name="noField-orModifier" value=" |+" type="hidden" />
                <input type="text" name="noField-or" class="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:message key="core.search.form.without" />
            </th>
            <td>
                <input name="noField-notModifier" value="-|0" type="hidden" />
                <input type="text" name="noField-not" class="text" />
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="timePeriod"  styleClass="label"  key="core.search.form.timePeriod" colon="false" helpTip="false" />
            </th>
            <td>
                <html:select property="timePeriod">
                    <html:option value="0" key="core.search.form.timePeriod.anytime" />
                    <html:option value="1" key="core.search.form.timePeriod.lastday" />
                    <html:option value="7" key="core.search.form.timePeriod.lastweek" />
                    <html:option value="30" key="core.search.form.timePeriod.pastmonth" />
                    <html:option value="90" key="core.search.form.timePeriod.past3months" />
                    <html:option value="180" key="core.search.form.timePeriod.past6months" />
                    <html:option value="360" key="core.search.form.timePeriod.pastyear" />
                </html:select>
            </td>
        </tr>
        <tr>
            <th>
                <atleap:label property="searchLanguage" key="core.search.form.language" styleClass="label" colon="false" helpTip="false" />
            </th>
            <td>
                <html:select property="searchLanguage" value="">
                    <html:option value="">
                        <atleap:message key="core.search.form.allLanguages" />
                    </html:option>

					<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
						<html:option value="${contentLocale.identifier}">
							<atleap:fieldValue valueMap="${contentLocale.title}" />
						</html:option>
					</atleap:iterator>
				</html:select>
            </td>
        </tr>
    </table>
    <html:hidden property="query" />

    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.search"/></atleap:submit>

</atleap:form>

